<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>25.评分组件</title>
    <script type="text/javascript" src="../layui-v2.7.6/layui/layui.js"></script>
    <script type="text/javascript" src="../layui-v2.7.6/layui/jquery-1.10.1.js"></script>
    <link rel="stylesheet" href="../layui-v2.7.6/layui/css/layui.css">
</head>
<body>
<div id="test1"></div>

<script>
    layui.use('rate', function(){
        var rate = layui.rate;

        //渲染
        var ins1 = rate.render({
            elem: '#test1'  //绑定元素
            ,value: 3
            // ,readonly: true
            ,text: true
            ,setText: function(value){
                var arrs = {
                    '1': '极差'
                    ,'2': '差'
                    ,'3': '中等'
                    ,'4': '好'
                };
                this.span.text(arrs[value] || ( value + "星"));
            }
            ,choose: function(value,text){
                layer.msg(text)
                console.log(this.span[0].textContent)
            }
        });
    });
</script>
</body>
</html>